package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldMaterialAppDto;
import com.cleaningcloud.cld.domain.vo.CldMaterialAppVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.service.ICldMaterialAppService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 项目申请Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/materialApp")
public class CldMaterialAppController extends BaseController
{
    @Autowired
    private ICldMaterialAppService cldMaterialAppService;

    /**
     * 查询项目申请列表
     */
    @RequiresPermissions("cld:materialApp:list")
    @GetMapping("/list")
    public TableDataInfo list(CldMaterialAppDto cldMaterialApp)
    {
        startPage();
        List<CldMaterialAppVo> list = cldMaterialAppService.selectCldMaterialAppList(cldMaterialApp);
        return getDataTable(list);
    }



    /**
     * 获取项目申请详细信息
     */
    @RequiresPermissions("cld:materialApp:query")
    @GetMapping(value = "/{materialAppId}")
    public AjaxResult getInfo(@PathVariable("materialAppId") Long materialAppId)
    {
        return success(cldMaterialAppService.selectCldMaterialAppByMaterialAppId(materialAppId));
    }

    /**
     * 新增项目申请
     */
    @RequiresPermissions("cld:materialApp:add")
    @Log(title = "项目申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldMaterialAppDto cldMaterialApp)
    {
        return toAjax(cldMaterialAppService.insertCldMaterialApp(cldMaterialApp));
    }

    /**
     * 修改项目申请
     */
    @RequiresPermissions("cld:materialApp:edit")
    @Log(title = "项目申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldMaterialAppDto cldMaterialApp)
    {
        return toAjax(cldMaterialAppService.updateCldMaterialApp(cldMaterialApp));
    }


    /**
     * 项目申请审核
     */
    @RequiresPermissions("cld:materialApp:audit")
    @Log(title = "项目申请审核", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody CldMaterialAppDto cldMaterialApp)
    {
        return toAjax(cldMaterialAppService.auditCldMaterialApp(cldMaterialApp));
    }

    /**
     * 删除项目申请
     */
    @RequiresPermissions("cld:materialApp:remove")
    @Log(title = "项目申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{materialAppIds}")
    public AjaxResult remove(@PathVariable Long[] materialAppIds)
    {
        return toAjax(cldMaterialAppService.deleteCldMaterialAppByMaterialAppIds(materialAppIds));
    }
}
